﻿#ifndef LOGIN_H
#define LOGIN_H
#include <QWidget>
#include<QMessageBox>
#include<QThread>
#include<unordered_map>
#include <QDateTime>
#include <QToolButton>
#include"connectthread.h"
#include"addfriendwidget.h"
#include"addfriendlistwidget.h"
#include "widget.h"
#include"message.h"
#include"Firend.h"
using namespace std;
namespace Ui {
class MainMeau;
}

class MainMeau : public QWidget
{
    Q_OBJECT
public:
    explicit MainMeau(SOCKET sockCli,QString qq,QString pwd,QWidget *parent = nullptr);
    ~MainMeau();
    void initMainMeau();
    void initInterface();//初始服务器传来信息接口 信号+槽
    //与服务器通信的socket
    SOCKET sockCli;
    //该账号的qq和密码
    QString qq;
    QString pwd;
    //好友相关
    std::unordered_map<std::string,Firend> friends;
    std::unordered_map<std::string,Widget*> friendsOfWidget;
    std::unordered_map<std::string,QPushButton*> friendsOfBtn;
    //新朋友相关
    unordered_map<string,string> newFriend;
    //信息包
    Message m;
private:
    Ui::MainMeau *ui;
    //监听服务器线程相关
    ConnectThread* ConnectThreadClass;
    QThread* QThreadOfConnectThread;
protected:
    //窗口关闭事件
    void closeEvent(QCloseEvent *event);
public slots:
    void showMessage(Message m); 
    void showFirendList(Message m);
    void updateNewFriendList(Message m);//更新   newFriend   的unordered_map
    void addFriendSucessfully(Message m);
    void requestAddFriend(Message m);
private slots:
    void on_addFriendButton_clicked();
    void on_newFriend_clicked();
};


#endif // LOGIN_H
